# -*- coding: utf-8 -*-
'''
    date:2017-06-05 hqk
    spider newadd rest class
'''

from sys import argv

from dianp_newadd import DianpNewaddHandle
from dianp_update import DianpUpdateHandle
from common.dianp_log import DianpLog
from dianp_threads import DianpThreads
from config.setting import RESTNEW, RESTUPDATE

class dianpWorker(object):
    def __init__(self):
        self.newaddHandle = DianpNewaddHandle()
        self.updateHandle =  DianpUpdateHandle()
        self.HandleTh = DianpThreads()
        self.taskDict = {RESTNEW:self.newaddHandle, RESTUPDATE:self.updateHandle}
        
        
    def main(self, taskName):
        if taskName in self.taskDict.keys():
            self.taskDict[taskName].start()
        else:
            print 'error task name, please check'
    
        

if len(argv) < 2:
    print 'please input task name'      
    exit()

handle = dianpWorker()
handle.main(argv[1])
    
